


var main={
    option:{
        useEasing : true,
        useGrouping : true,
        separator : ',',
        decimal : '.',
        prefix : '',
        suffix : ''
    },
    init:function () {
        showTaskList();
    }
}
main.init();


function loadTask() {
    data = []
    $.ajax({
        type:"post",
        async:false,
        url:"/userRemark/queryLastUserRemark",
        success:function(result) {
            if (result.code == property.successCode) {
                data = result.data;
            } else{
                errorMsg(result.msg);
            }
        },
        error:function(result) {
            errorMsg("系统异常");
        }
    });
    return data;
}

function showTask(id) {
    localStorage.id = id
    parent.$t.goToPageSimple("/userRemark/detailInfo","查看","/main");
}







function getAppointment() {
    data = []
    $.ajax({
        type:"get",
        async:false,
        url:"/doctorAppointment/queryLastAppointment",
        success:function(result) {
            if (result.code == property.successCode) {
                data = result.data;

            } else{
                errorMsg(result.error.message);
            }
        },
        error:function(result) {
            errorMsg("系统异常");
        }
    });
    return data;
}



function showTaskList(){
    var undoTask = loadTask()
    var appointment = getAppointment()
    //加载待办
    layui.use('table', function(){
        var table = layui.table;
        var cols = [
            {field:'userName', title:'留言人'}
            ,{field:'content', title:'留言内容'}
            // ,{field:'createTime', title:'创建时间',templet: function(res){
            //         return formatDate(res.createTime);
            //     }}
            ,{fixed: 'right', title:'操作', width:200,templet: function(res){
                    return '</span><a href="#" data-id="'+res.id+'" class="tongzhiRight showTask"><span>查看</span>';
                }}
        ]
        var noticeCols = [
            {field:'patientName', title:'病人名称'}
            ,{field:'doctorName', title:'医生名称'}
            ,{field:'appointmentTime', title:'预约时间',templet: function(res){
                    return formatSimpleDate(res.appointmentTime);
                }}
            ,{field:'appointmentDetailTime', title:'具体时间段'}
        ]
        table.render({
            elem: '#undoTable'
            ,data:undoTask
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,cols: [cols]
        });

        table.render({
            elem: '#appointmentTable'
            ,data:appointment
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,cols: [noticeCols]
        });

        table.on('tool(undoTable)', function(obj){
            var data = obj.data;
            if (obj.event === 'edit'){
                localStorage.userRemarkId = data.id;
                parent.$t.goToPage(this, "/main");
            }
        });

        $(".showTask").click(function () {
            showTask($(this).attr("data-id"));
        })
        $(".showNotice").click(function () {
            showNotice($(this).attr("data-id"));
        })
        $("#setShortcutEntrance").click(function () {
            setShortcutEntrance();
        })

        $("#liuyan").click(function () {
            parent.$t.goToPage(this, "/main");
        })
    });
}


